/*   1:    */ package org.jetbrains.generate.tostring.template;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.util.Comparing;

import java.util.*;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */ 
/*  14:    */ @State(name="ToStringTemplates", storages={@com.intellij.openapi.components.Storage(file="$APP_CONFIG$/toStringTemplates.xml")})
/*  15:    */ public class TemplatesManager
/*  16:    */   implements PersistentStateComponent<TemplatesState>
/*  17:    */ {
/*  18:    */   public static TemplatesManager getInstance()
/*  19:    */   {
/*  20: 36 */     return (TemplatesManager)ServiceManager.getService(TemplatesManager.class);
/*  21:    */   }
/*  22:    */   
/*  23: 39 */   private TemplatesState a = new TemplatesState();
/*  24:    */   
/*  25:    */   public TemplatesManager()
/*  26:    */   {
/*  27: 42 */     for (TemplateResource localTemplateResource : TemplateResourceLocator.getDefaultTemplates()) {
/*  28: 43 */       addTemplate(localTemplateResource);
/*  29:    */     }
/*  30:    */   }
/*  31:    */   
/*  32:    */   public TemplatesState getState()
/*  33:    */   {
/*  34: 48 */     return this.a;
/*  35:    */   }
/*  36:    */   
/*  37:    */   public void loadState(TemplatesState paramTemplatesState)
/*  38:    */   {
/*  39: 52 */     this.a = paramTemplatesState;
/*  40:    */   }
/*  41:    */   
/*  42:    */   public void addTemplate(TemplateResource paramTemplateResource)
/*  43:    */   {
/*  44: 56 */     this.a.templates.add(paramTemplateResource);
/*  45:    */   }
/*  46:    */   
/*  47:    */   public void removeTemplate(TemplateResource paramTemplateResource)
/*  48:    */   {
/*  49: 60 */     Iterator localIterator = this.a.templates.iterator();
/*  50: 61 */     while (localIterator.hasNext())
/*  51:    */     {
/*  52: 62 */       TemplateResource localTemplateResource = (TemplateResource)localIterator.next();
/*  53: 63 */       if (Comparing.equal(localTemplateResource.getFileName(), paramTemplateResource.getFileName())) {
/*  54: 64 */         localIterator.remove();
/*  55:    */       }
/*  56:    */     }
/*  57:    */   }
/*  58:    */   
/*  59:    */   public Collection<TemplateResource> getAllTemplates()
/*  60:    */   {
/*  61: 70 */     TemplateResource[] arrayOfTemplateResource = TemplateResourceLocator.getDefaultTemplates();
/*  62: 71 */     HashSet localHashSet = new HashSet();
/*  63: 72 */     for (Object localObject2 : arrayOfTemplateResource) {
/*  64: 73 */       localHashSet.add(localObject2.getFileName());
/*  65:    */     }
/*  66: 75 */     ??? = new LinkedHashSet(Arrays.asList(arrayOfTemplateResource));
/*  67: 76 */     for (TemplateResource localTemplateResource : this.a.templates) {
/*  68: 77 */       if (!localHashSet.contains(localTemplateResource.getFileName())) {
/*  69: 78 */         ((Collection)???).add(localTemplateResource);
/*  70:    */       }
/*  71:    */     }
/*  72: 81 */     return ???;
/*  73:    */   }
/*  74:    */   
/*  75:    */   public TemplateResource getDefaultTemplate()
/*  76:    */   {
/*  77: 85 */     for (TemplateResource localTemplateResource : getAllTemplates()) {
/*  78: 86 */       if (Comparing.equal(localTemplateResource.getFileName(), this.a.defaultTempalteName)) {
/*  79: 87 */         return localTemplateResource;
/*  80:    */       }
/*  81:    */     }
/*  82: 91 */     return (TemplateResource)getAllTemplates().iterator().next();
/*  83:    */   }
/*  84:    */   
/*  85:    */   public void setDefaultTemplate(TemplateResource paramTemplateResource)
/*  86:    */   {
/*  87: 96 */     this.a.defaultTempalteName = paramTemplateResource.getFileName();
/*  88:    */   }
/*  89:    */   
/*  90:    */   public void setTemplates(List<TemplateResource> paramList)
/*  91:    */   {
/*  92:100 */     this.a.templates.clear();
/*  93:101 */     for (TemplateResource localTemplateResource : paramList) {
/*  94:102 */       if (!localTemplateResource.isDefault()) {
/*  95:103 */         this.a.templates.add(localTemplateResource);
/*  96:    */       }
/*  97:    */     }
/*  98:    */   }
/*  99:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.generate.tostring.template.TemplatesManager

 * JD-Core Version:    0.7.0.1

 */